'use strict';const _zh=0,_Ks=1,_is=2,_Zs=3,_zu=4,_Pa=5,_Wh=6,_4y=7,_td=8,_9a=1,_3f=2,_rp=10,_he=3,_Ls=4,_We=5,_Ds=6,_2d=7,_Ia=8,_He=9,_el=11,_dr=12,_0d=13,_Qi=14,_Bo=15;let _6a={},_zg,_ad={};
{let p,w,N,O,P,G,H,Q;var _dh=function(c,a={},d){p={map:{},list:[],urlTests:[],combinSequences:{},gestures:[],neededCaretSt:0};w={trigRepTime:.6,trigStepTime:1.5}.add(d);w.dfltWldcrd=null==w.dfltWldcrd?_Ly:+w.dfltWldcrd;_ih(w.dfltGestPreconds=a.preconds||{},"chromeState",{active:1});P=O=N=0;G=[{},{}];_Nt=H=!1;_ad={};_zg=parseInt(_xg.substr(22,2),36);for(let [h,m]of c)m.disabled||K(m.triggers||[],{type:_Ks,param:+h+_zg});_Kg(a,"begin",0,"combins","length")&&_Kg(a,"end",0,"combins","length")&&(K(a.end,
{type:_zu,state:!1}),K(a.begin,{type:_zu,state:!0,timeout:a.timeout}));c=p;w=G=p=null;return c};let K=function(c,a){Q=0;for(let d of c)_mr(d)||R(d,a)},n=function(c,a,d=[],h=[],m="back"){m=m.split(" ");a=a.sc();let k=p.list.push(a)-1;a.preconds=X(d,h,k,"noExtraActions".in(m));0==a.preconds.length&&delete a.preconds;c=S(c);for(let l of c)_ih(p.map,l+20127+171,[])["front".in(m)?"unshift":"push"](k);return k},Y=function(c){c={part:c.part,regex:_0h(c.value,c.type).source};let a=_xr(p.urlTests,c);-1==a&&
(a=p.urlTests.push(c)-1);return a},X=function(c,a,d,h=!1){let m=[],k=[],l=[],t={};for(let b of c.concat(a)){a=null;if(b.urlTest)b.urlTest.value&&(a={type:_he,testIdx:Y(b.urlTest)});else if("chromeState"in b)a=b.chromeState||{},a=[void 0,{type:_3f,value:1},{type:_3f,value:0},{type:_rp,value:1},{type:_rp,value:0},{type:_3f,value:0,negate:!0},{type:_3f,value:1,negate:!0},null][(a.active?1:0)|(a.inactive?2:0)|(a.closed?4:0)];else if(b.menuState)a={type:_0d,menuNum:_Eg(b.menuState.menuId)};else if(b.caretState){var f=
b.caretState;f.off&&f.on&&f.omnibox||(a={type:_dr,value:f.off|f.on<<1|f.omnibox<<2},p.neededCaretSt|=a.value)}else b.mouseOver?a={type:_Qi,value:b.mouseOver.region}:b.swtchState?(f=b.swtchState,f.swtchId&&(a={type:_We,swtchId:+_Uk(f.swtchId)[1],state:f.state,oper:_or(f.oper)})):b.wildcard?(f=b.wildcard==_Ly?w.dfltWldcrd:b.wildcard)&&(a={type:_Ds,value:f}):"keyStateChange"in b?a={type:_He,value:+b.keyStateChange}:b.prevSeqStep?a={type:_Ls,maxTime:b.maxTime}.add(b.prevSeqStep):"actionState"in b?a={type:_2d,
value:b.actionState,actIdx:b.actIdx}:"actionDone"in b?a={type:_Ia,value:+b.actionDone,actIdx:b.actIdx}:b.mouseGestState?a={type:_el,value:b.mouseGestState}:b.clipFmt?a={type:_Bo,value:b.clipFmt}:b.keyEvt&&(f=_3j(b.keyEvt,!0),f.isDownUp&&!f.miscNum&&(b.keyEvt=f.num|f.type),a=S(b.keyEvt),a={type:_9a,key1:a[0],key2:a[1],toggleState:b.toggleState},_Du(f)&&(p.usesJoystk=!0),!h&&b.block&&L(f)&&!b.toggleState&&(f=n(b.keyEvt,{type:_zh,block:!0},c),n(b.keyEvt,{type:_Wh,actIdx:d},T(c),[{keyStateChange:!0}]),
p.list[d].type.in(_td,_Zs)||(n(b.keyEvt|_Go,{type:_is,param:_or("Y")},E(c),[{actionDone:!0,actIdx:f},{actionState:_or("D"),actIdx:d,negate:!0}]),b.block==_Ke&&n(b.keyEvt|_Go,{type:_zh,block:!0},E(c),[{actionDone:!0,actIdx:f},{actionState:_or("D"),actIdx:d}]))));if(a){f=+b.negate==_Ff;if(+b.negate&&!f||"not"==b.oper)a.negate=!0;!a.type.in(_he,_0d,_Qi)||a.negate||f||"and"==b.oper?a.type==_Qi?k.push(a):a.type==_We?l.push(a):m.push(a):_ih(t,a.type,[]).push(a)}}l.length&&(l[l.length-1].mark=_or("S"));
c=[];for(let [,b]of t)1==b.length?c.unshift(b[0]):(b[0].mark=_or("F"),b[b.length-1].mark=_or("L"),c.push(...b));return m.concat(l,c,k)},Z=function(c){const a={[_Bs]:Symbol(),[_ld]:"domain",[_ss]:"mainDomain",[_Ay]:"path"};let d=[];for(let h of c)if(h.value)d[h.negate?"unshift":"push"]({part:a[h.part],regex:_0h(h.value,h.type),negate:h.negate});return h=>{let m=_qd(h),k=[];for(let f of m){a:{var l=_Ss[f]||_7j(_os[f]);for(let b of d){var t=b.negate;if(b.regex.test(b.part==a[_Bs]?l:_dk(l,b.part))==(b.negate!=
_Ff)){l=!b.negate;break a}}l=t}l&&k.push(f)}return k.length?m.length==k.length?h:_3o(null,{tabs:k}):!1}},aa=function(c){let a=[];for(let d of c||[])if(d.mouseMove&&(c=p.gestures.indexOf(d.mouseMove),-1==c&&(c=p.gestures.push(d.mouseMove)-1),d.eventId=c|_Se),a.push(d),1<+d.repCount){c=d.sc().del("negateSeq").add({maxTime:w.trigRepTime});for(let h=1;h<+d.repCount;++h)a.push(c)}return a},R=function(c,a){const d=_9g(c),h=a.sc(),m=++N,k={},l=aa(d.combins);var t={seqId:m,stepId:0};let f=!1;_ih(d,"preconds");
for(var b=0;b<l.length;++b){let e=l[b];if(!e.eventId)continue;let g=_3j(e.eventId,!0),z,B=[];if(g.type==_Xs){if(g.num==_sd)B.push({clipFmt:e.clipFmt}),e.diffCont&&(e.eventId=_vk|_Xs,g=_3j(e.eventId,!0));else if(g.num==_go){if(!e.evtName)continue;_ih(p,"extEvtNames")[e.evtName.trim().toUpperCase()]=e.eventId-=P++;g=_3j(e.eventId,!0)}else _d(g.num)&&e.btnId&&(e.eventId=e.btnId,e.block=e.btnId<_Be?_Hr:_Ke,z={mouseOver:[{region:_Ej+1+g.num-_Y}]},g=_3j(e.eventId,!0));g.num<_sd&&(_ad[g.num]=!0)}else g.type==
_Se&&(f=!0);let I=L(g);g.isDownUp&&!g.miscNum&&(e.eventId=g.num|g.type);var A=b==l.length-1;let C=U(e),u=ba(e,g),ca=u?U(u):void 0;_Du(g)&&(p.usesJoystk=!0);1<l.length&&(k[g.devId]=1,k.add(C),f&&(k[_Wo]=1));const r=A?e.noAutoRep&&I&&g.devId==_ps?h.add({autoRep:!1}):h:{type:_4y,param:{seqId:m,stepId:b+1}};r.block=!!e.block;r.PBC=C;if(0==b)if(f)for(let [y,x]of w.dfltGestPreconds)_ih(d.preconds,y,x);else _ih(d.preconds,"chromeState",{active:1,inactive:g.type==_Xs||e.btnId});const M=r.type==_zu&&r.state,
V=r.type==_zu&&!r.state;M&&(B.push({mouseGestState:_or("S")},{keyStateChange:!0}),d.preconds=_wp(G));V&&(B.push({mouseGestState:_or("S"),negate:!0},{keyStateChange:!0}),d.preconds={},delete e.wildcard);let v=[];var q=z?Object.assign({},d.preconds,z):d.preconds;for(let [y,x]of q)if(x){if("urlTests"==y)y="urlTest";else if("menuState"==y)x=d.preconds[y]=_bt(x);else if("evtUrl"==y){A&&g.type==_Xs&&g.num<_f&&(r.param|=++Q<<24,_6a[r.param]=Z(x),_Nt=!0);continue}_Mg(x)||(x=[x]);for(let W of x)v.push(W.sc().keep("negate",
"oper").add({[y]:W}))}0==b&&g.isDownUp&&g.num==_mw&&(_Pt(e.preconds)||1==C[_Lk]&&1==Object.keys(C))&&(q=H?{mouseOver:{region:_Cd},negate:!0}:{urlTest:{part:_Bs,type:"starts",value:_Ky.runtime.getURL(_gi)},negate:!0},v.push(q),H^=1);const F=I?e.holdPeriod|0:0;1<l.length&&(0<b||da(e.eventId,l.slice(1))&&!l[b+1].negateSeq)&&v.push({prevSeqStep:t,negate:e.negateSeq,maxTime:1E3*(e.maxTime||w.trigStepTime)+F});t=_3y(e.preconds||[],e.wildcard?{wildcard:+e.wildcard}:[]);let J=e.eventId;F&&(J=++O|_9r);A&&
1<l.length&&n(J,{type:_4y,param:{seqId:m,stepId:b+1},PBC:C},v,t,"noExtraActions");q=n(J,r,v,t.concat(B));var D=void 0;F&&(D=r.sc().del("param").add({type:A&&!e.noAutoRep?_Zs:_td,evtId:J,delay:F}),D=n(e.eventId,D,v,t.concat(B)),n(u.eventId,{type:_Pa,actIdx:D}));e.block==_Ke&&_Yh(g)&&(A={type:_zh,block:!0},I?n(u.eventId,A,[],[{actionDone:!0,actIdx:q}]):n(u.eventId,A.add({PBC:ca}),v,t.concat(B)));if(r.block&&I){n(u.eventId,{type:_is,param:_or("N")},[],[{actionState:_or("D"),actIdx:q}]);if(M||V)n(e.eventId,
{type:_zh,block:!0},E(v),[{actionState:0,negate:!0,actIdx:q},{keyStateChange:!1}]),M&&(n(u.eventId,{type:_is,param:_or("Y")},[],[{mouseGestState:_or("S")},{actionState:_or("I"),actIdx:q}]),n(u.eventId,{type:_zh,block:!0},[],[{mouseGestState:_or("S")},{actionState:_or("D"),actIdx:q}]),n(u.eventId,{type:_Wh,actIdx:q},[],[{mouseGestState:_or("S")},{actionState:0,actIdx:q,negate:!0}]));F&&(n(u.eventId,{type:_is,param:_or("Y")},E(v),[{actionDone:!0,actIdx:D},{actionState:_or("D"),actIdx:q,negate:!0}]),
n(u.eventId,{type:_zh,block:!0},E(v),[{actionDone:!0,actIdx:D},{actionState:_or("D"),actIdx:q}]))}g.isDownUp&&n(e.eventId,{type:_Wh,PBC:C,actIdx:q},T(v),[{keyStateChange:!0}],"noExtraActions front");t=r.param}if(f){const [e,g]=G;d.preconds.chromeState||(_6p("emptyChromeState",{triggerObj:d,origTriggerObj:c,origActionData:a}),d.preconds.chromeState={});_ih(e,"chromeState").add([...d.preconds.chromeState].filter(([,z])=>z));null!==e.caretState&&(d.preconds.caretState?_ih(e,"caretState").add([...d.preconds.caretState].filter(([,
z])=>z)):e.caretState=null);_fk("urlTests",e,g,d.preconds);_fk("menuState",e,g,d.preconds);_fk("mouseOver",e,g,d.preconds);_fk("swtchState",e,g,d.preconds)}1<l.length&&(p.combinSequences[m]={usedDevs:Object.keys(k).map(e=>+e),lastStepId:b});H&&R(c,a);return q},S=function(c){let a=_3j(c,!0);if(!_Yh(a))return[c];let d=(_Ci[a.num]||[])[1];if(_Mg(d)){c=[];for(let h of d)c.push(h|a.type);return c}return[c]},L=function(c){return _Yh(c)&&c.type==_Ku},ba=function(c,a){if(_Yh(a))return c.sc().add({eventId:c.eventId^
_Go})},E=function(c){return c.filter(a=>!a.prevSeqStep)},T=function(c){return c.filter(a=>!a.mouseOver)},U=function(c){let a={},d=function(k){L(k)&&(a[k.devId]=(a[k.devId]||0)+1)},h=_3j(c.eventId,!0);d(h);let m;for(let k of c.preconds||[])k.toggleState?m=!0:d(_3j(k.keyEvt,!0));!a[h.devId]&&_Yh(h)&&h.type==_Go&&(a[h.devId]=-1);m&&!a[_ps]&&(a[_ps]=-1);return a},da=function(c,a){for(let d of a)if(d.eventId==c)return!0;return!1}};
